package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.Dao.Impl.CompanyDaoImpl;
import com.ysd.Dao.Impl.NewsDaoImpl;
import com.ysd.Dao.Impl.ProductDaoImpl;
import com.ysd.entity.Company;
import com.ysd.entity.News;
import com.ysd.entity.Product;


public class HomeServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//调用实现类的方法
		CompanyDaoImpl cDao = new CompanyDaoImpl();
		Company  c = cDao.getCompany();
		request.setAttribute("c", c);
		//调用实现类的方法
		NewsDaoImpl nDao = new NewsDaoImpl();
		List<News> jx = nDao.getNewsList(4);
		request.setAttribute("jx", jx);
		//调用产品图片
		ProductDaoImpl cpDao = new ProductDaoImpl();
		List<Product> pran = cpDao.getProductranderList();//产品表所有数据
		request.setAttribute("pran", pran);	
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
